import sys
from loguru import logger
import config

def configure_logging():

    # 配置日志文件路径和保留时间
    log_path = config.log_path
    rotation_size = config.rotation_size
    retention_period = config.retention_period


    # 添加日志处理器到logger
    logger.add(log_path, rotation=rotation_size, retention=retention_period)

    # logger.add("logs_storage/{time}.log", rotation="500 MB", retention="10 days")  # 将日志输出到文件中

    # 将日志同时输出到控制台和文件
    logger.configure(handlers=[
        {"sink": log_path, "rotation": "500 MB", "retention": "10 days"},
        # {"sink": sys.stdout, "level": "INFO"},
    ])
    return logger
